package GC_requestUsingSA;


import static org.junit.Assert.assertEquals;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.PrintStream;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import FamilyTherapy.GCWindow;
import FamilyTherapy.Player;
import FamilyTherapy.SayActCard;

public class testGCWindow_requestUsingSA_2 {

	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test
	public void testRequestUsingSA_2() {
		GCWindow gwindow = new GCWindow();
		Player[] p ={new Player("a",1),new Player("b",2)};
		SayActCard s=new SayActCard(0);
		
		final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
		System.setOut(new PrintStream(outContent));
		
		
		String expected = "Do you want to do this Say and Act task ? Enter \'y' es or \'n'o : \n" + 
		"Have you finished this task. Enter \'y' es or \'n'o : \n" + 
		"You have been given 3 point.\n";

	
		//for input
		String data = "y y"; 	//data to be input 
		InputStream stdin = System.in; 
		try {   
			System.setIn(new ByteArrayInputStream(data.getBytes()));	//put data to input stream
			gwindow.requestUsingSA(s,0,p);	//for getting data from input stream
		} 
		finally {  
			System.setIn(stdin); 	//reset input stream as System.in
		} 
		
		//for testing
		assertEquals(expected,outContent.toString());
		
	}

}
